package com.yeyks.task;

import com.yeyks.search.constants.EsIndexConstant;
import com.yeyks.search.service.hotel.EsImportHotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务删除过期房态
 * @author: dagny
 * @date: 2019/11/13 0013 16:09
 */
@Component
@Slf4j
public class CnDelCalendarTask {

    @Autowired
    private EsImportHotelService esImportHotelService;

    @Scheduled(cron = "${schedule.calendar.esData}")
    public void importHotelInEs(){

        log.info("开始执行删除数据");
        //执行数据库的过期房态删除
        Boolean yyks = esImportHotelService.delOverTimeCalendarData(EsIndexConstant.INDEX_HOTEL2, "yyks", 1000, 1);
        if(yyks){
            //执行CN酒店中的过期房态删除
            yyks = esImportHotelService.delOverTimeCalendarData(EsIndexConstant.INDEX_HOTEL2, "cn", 1000, 1);
        }
        if(yyks){
            log.info("删除过期房态数据完成");
        }
    }

}
